/**
 * @(#) InterfaceMethod.java
 */

package cn.edu.sjtu.se.dslab.component.method;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import cn.edu.sjtu.se.dslab.component.data.DomainEntity;

@Entity
@Table(name = "interface_method")
public class InterfaceMethod implements Serializable {
	private static final long serialVersionUID = 1L;

	private long id;
	
	private String name;

	private DomainEntity returnType;

	private String arguments;

	private String methodSigniture;

	private String description;
	
	/**
	 * 该函数的实现代码，只有对应于struct时才会有
	 */
	private String implementation;
	
	/**
	 * 用以记录该函数所依赖的所有的datatype,记录id id之间以分号相隔
	 */
	private String depType;

	private ComponentInterface cInterface;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)  
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}
	
	@Lob
	@Column(name = "implementation", columnDefinition = "BLOB", nullable = true)
	public String getImplementation() {
		return implementation;
	}

	public void setImplementation(String implementation) {
		this.implementation = implementation;
	}
	
	@Column(name = "name", nullable = false, length = 255)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "dep_type", nullable = true, length = 1000)
	public String getDepType() {
		return depType;
	}

	public void setDepType(String depType) {
		this.depType = depType;
	}

	@ManyToOne(cascade = { CascadeType.REFRESH } )
	@JoinColumn(name = "return_type_id", nullable = false)
	public DomainEntity getReturnType() {
		return returnType;
	}

	public void setReturnType(DomainEntity returnType) {
		this.returnType = returnType;
	}

	@Column(name = "arguments", nullable = true, length = 255)
	public String getArguments() {
		return arguments;
	}

	public void setArguments(String arguments) {
		this.arguments = arguments;
	}

	@Column(name = "method_signiture", nullable = true, length = 255)
	public String getMethodSigniture() {
		return methodSigniture;
	}

	public void setMethodSigniture(String methodSigniture) {
		this.methodSigniture = methodSigniture;
	}

	@Column(name = "description", nullable = true, length = 255)
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@ManyToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "interface_id", nullable = true)
	public ComponentInterface getcInterface() {
		return cInterface;
	}

	public void setcInterface(ComponentInterface cInterface) {
		this.cInterface = cInterface;
	}

}
